﻿using System;

namespace ZeBobo5.LibraryHelper.Core
{
    /// <summary>
    /// AS/400 Helper Class
    /// </summary>
    public class AS400Helper
    {
        #region Nested type: DateTimeHelper

        /// <summary>
        /// DateTime Helper Class
        /// </summary>
        public class DateTimeHelper
        {
            /// <summary>
            /// Return the string value of date
            /// </summary>
            /// <param name="date">The current date to parse</param>
            /// <returns>Returns the YYYYMMDD of the date</returns>
            public static string ParseDate(DateTime date)
            {
                return (date.Year*10000 + date.Month*100 + date.Day).ToString();
            }

            /// <summary>
            /// Return the string value of time
            /// </summary>
            /// <param name="time">The current time to parse</param>
            /// <returns>Returns the HHMMSS of the date</returns>
            public static string ParseTime(DateTime time)
            {
                return (time.Hour*10000 + time.Minute*100 + time.Second).ToString();
            }
        }

        #endregion

        #region Nested type: StringHelper

        /// <summary>
        /// String Helper Class
        /// </summary>
        public class StringHelper
        {
            ///<summary>
            /// Complete string with space on the left to lenght of result
            ///</summary>
            ///<param name="value">Current string value</param>
            ///<param name="lenghtOfResult">Lenght which the result must have</param>
            public static string LeftBlank(string value, int lenghtOfResult)
            {
                return value.PadLeft(lenghtOfResult, ' ');
            }

            /// <summary>
            /// Complete string with space on the right to lenght of result
            ///</summary>
            ///<param name="value">Current string value</param>
            ///<param name="lenghtOfResult">Lenght which the result must have</param>
            public static string RightBlank(string value, int lenghtOfResult)
            {
                return value.PadRight(lenghtOfResult, ' ');
            }
        }

        #endregion
    }
}